﻿// owner 蒋家伟

#pragma once
#include "IGenericElement.h"

// 序列化
#include "DBSchemaObject.h"
#include "ObjectReflectDeclare.h"
#include "DataSerializeDefine.h"

// 组件
#include "IExternalData.h"
#include "ElementBaseCompoent.h"

namespace jsdk
{
    class GenericElement : public DBSchemaObject, public IGenericElement
    {
        OBJECT_SERIALIZE_DECLARE_DERIVED2(jsdk, GenericElement, L"{DE37B304-02EE-4C07-9DE8-B16ACAD461A6}", DBSchemaObject, IGenericElement)
            DATA(OwnerPtr<ElementBaseCompoent>, opElementBaseCompoent)
            DATA(OwnerPtr<IExternalData>, opExternalData)
    public:
        static OwnerPtr<jsdk::GenericElement> create(
            const UniqueId& typeUid, 
            OwnerPtr<IExternalData> opExternalData, 
            bool isTemp);

    private:
        // 继承IElement
        virtual const IDocument* getDocument() const override;
        virtual IDocument* getDocument() override;

        virtual ElementId getElementId() const override;
        virtual const IElementBasicInfomation* getBasicInfomation() const override;
        virtual IElementBasicInfomation* getBasicInfomation() override;
        virtual void setDocument(IDocument* pDoc) override;
        virtual void setElementId(const ElementId& elementId) override;
        virtual void setComponentOwnerElement() override;

        // 继承IGenericElement
        virtual const IExternalData* getExternalData() const override;
        virtual  IExternalData* getExternalData() override;

        // owner
        ElementBaseCompoent* getElementBaseCompoent();
        const ElementBaseCompoent* getElementBaseCompoent() const;
    };
}
